Skip to content

fix(Number): preserve already integral values in Number.round - #11425

Closed
aloneangel45 wants to merge 1 commit into
Effect-TS:mainfrom
aloneangel45:fix/number-round-integral
Closed

aloneangel45 wants to merge 1 commit into
Effect-TS:mainfrom
aloneangel45:fix/number-round-integral

Conversation

@aloneangel45

Copy link
Copy Markdown
Contributor

Summary

Closes #11402.

  • Return self directly in Number.round when Number.isInteger(self), Number.isFinite(precision), and precision >= 0.
  • Avoids floating-point precision loss (e.g. 9007199254740990 rounding to 9007199254740989) and overflow (e.g. 1e308 turning into Infinity) from scaling integers by 10 ** precision only to divide back by the same factor, while preserving -0, non-finite inputs, and Math.round scaling semantics for non-integer/negative-precision/non-finite-precision cases.
  • Added unit tests in packages/effect/test/Number.test.ts and a patch changeset.

Verification

  • vitest run on packages/effect/test/Number.test.ts: 76/76 passed
  • tsc -p packages/effect/tsconfig.json --noEmit: passed
  • dprint check on modified files: passed

@changeset-bot

changeset-bot Bot commented Dec 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8598ae9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 43 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/vitest Patch
@effect/ai-amazon-bedrock Patch
@effect/ai-anthropic Patch
@effect/ai-cloudflare Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/ai-typesafe Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/chat-discord Patch
@effect/chat-slack Patch
@effect/chat-teams Patch
@effect/chat-telegram Patch
@effect/chat-whatsapp Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-cloudflare Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/graphql-generator Patch
@effect/openapi-generator Patch
@effect/ui-devtools Patch
@effect/ui-native Patch
@effect/ui-opentui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 40.45 KB 40.45 KB 0.00 KB (0.00%)
basic.ts 6.66 KB 6.66 KB 0.00 KB (0.00%)
batching.ts 11.90 KB 11.90 KB 0.00 KB (0.00%)
brand.ts 6.91 KB 6.91 KB 0.00 KB (0.00%)
cache.ts 12.16 KB 12.16 KB 0.00 KB (0.00%)
config.ts 23.89 KB 23.89 KB 0.00 KB (0.00%)
differ.ts 22.75 KB 22.75 KB 0.00 KB (0.00%)
http-client.ts 28.90 KB 28.90 KB 0.00 KB (0.00%)
http-router.ts 39.57 KB 39.57 KB 0.00 KB (0.00%)
logger.ts 12.34 KB 12.34 KB 0.00 KB (0.00%)
metric.ts 10.16 KB 10.16 KB 0.00 KB (0.00%)
optic.ts 7.14 KB 7.14 KB 0.00 KB (0.00%)
pubsub.ts 16.89 KB 16.89 KB 0.00 KB (0.00%)
queue.ts 13.71 KB 13.71 KB 0.00 KB (0.00%)
schedule.ts 12.46 KB 12.46 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 14.50 KB 14.50 KB 0.00 KB (0.00%)
schema-binary.ts 43.50 KB 43.50 KB 0.00 KB (0.00%)
schema-class.ts 22.50 KB 22.50 KB 0.00 KB (0.00%)
schema-codegen.ts 33.86 KB 33.86 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 30.95 KB 30.95 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 28.69 KB 28.69 KB 0.00 KB (0.00%)
schema-string-transformation.ts 16.26 KB 16.26 KB 0.00 KB (0.00%)
schema-string.ts 12.78 KB 12.78 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.86 KB 16.86 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 40.00 KB 40.00 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 21.64 KB 21.64 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 21.81 KB 21.81 KB 0.00 KB (0.00%)
schema-toFormatter.ts 21.90 KB 21.90 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 26.94 KB 26.94 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 21.96 KB 21.96 KB 0.00 KB (0.00%)
schema.ts 21.61 KB 21.61 KB 0.00 KB (0.00%)
stm.ts 14.96 KB 14.96 KB 0.00 KB (0.00%)
stream.ts 10.70 KB 10.70 KB 0.00 KB (0.00%)
supervisor.ts 12.13 KB 12.13 KB 0.00 KB (0.00%)

UI Bundle Size

Vite 8.4.0/Rolldown, production, default Oxc minification, es2023, ES modules, gzip level 9 per chunk. effect 4.2.0, Node v26.12.1. Effect-only client: 27408 B gzip (Δ 0 B vs base).

App Chunks Raw bytes Gzip bytes Added gzip B Δ raw bytes Δ gzip bytes
counter 1 175779 60647 33239 0 0
features 1 185431 64098 36690 0 0
menu 1 290229 98812 71404 0 0

@aloneangel45

Copy link
Copy Markdown
Contributor Author

Closing as #11419 already landed on \main\ to address this issue.

This branch is waiting to be deployed

1 waiting deployment
fork — 8598ae9e Waiting Dec 3, 2026 by aloneangel45 via approval-gate #29306
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Number.round can change an already integral value at positive precision

1 participant